package com.sys.SysModel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sys.common.annotation.Log;
import com.sys.common.core.controller.BaseController;
import com.sys.common.core.domain.AjaxResult;
import com.sys.common.enums.BusinessType;
import com.sys.SysModel.domain.SysModelFeeding;
import com.sys.SysModel.service.ISysModelFeedingService;
import com.sys.common.utils.poi.ExcelUtil;
import com.sys.common.core.page.TableDataInfo;

/**
 * 喂养模板Controller
 * 
 * @author ruoyi
 * @date 2025-09-29
 */
@RestController
@RequestMapping("/SysModel/SysModelFeeding")
public class SysModelFeedingController extends BaseController
{
    @Autowired
    private ISysModelFeedingService sysModelFeedingService;

    /**
     * 查询喂养模板列表
     */
    @PreAuthorize("@ss.hasPermi('SysModel:SysModelFeeding:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysModelFeeding sysModelFeeding)
    {
        startPage();
        List<SysModelFeeding> list = sysModelFeedingService.selectSysModelFeedingList(sysModelFeeding);
        return getDataTable(list);
    }

    /**
     * 导出喂养模板列表
     */
    @PreAuthorize("@ss.hasPermi('SysModel:SysModelFeeding:export')")
    @Log(title = "喂养模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysModelFeeding sysModelFeeding)
    {
        List<SysModelFeeding> list = sysModelFeedingService.selectSysModelFeedingList(sysModelFeeding);
        ExcelUtil<SysModelFeeding> util = new ExcelUtil<SysModelFeeding>(SysModelFeeding.class);
        util.exportExcel(response, list, "喂养模板数据");
    }

    /**
     * 获取喂养模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('SysModel:SysModelFeeding:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysModelFeedingService.selectSysModelFeedingById(id));
    }

    /**
     * 新增喂养模板
     */
    @PreAuthorize("@ss.hasPermi('SysModel:SysModelFeeding:add')")
    @Log(title = "喂养模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysModelFeeding sysModelFeeding)
    {
        return toAjax(sysModelFeedingService.insertSysModelFeeding(sysModelFeeding));
    }

    /**
     * 修改喂养模板
     */
    @PreAuthorize("@ss.hasPermi('SysModel:SysModelFeeding:edit')")
    @Log(title = "喂养模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysModelFeeding sysModelFeeding)
    {
        return toAjax(sysModelFeedingService.updateSysModelFeeding(sysModelFeeding));
    }

    /**
     * 删除喂养模板
     */
    @PreAuthorize("@ss.hasPermi('SysModel:SysModelFeeding:remove')")
    @Log(title = "喂养模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysModelFeedingService.deleteSysModelFeedingByIds(ids));
    }
}
